package com.ship.control.impl;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;

import com.ship.control.AbstractAdminFormController;
import com.ship.entity.User;
import com.ship.service.UserService;

/**
 * 用户登录
 * @author wqf
 * @version  Nov 25, 2011 9:26:07 AM
 */
public class ChangePassController extends AbstractAdminFormController {
	
	public ChangePassController(){
		this.setCommandClass(User.class);
	}
	
	protected void submit(HttpServletRequest request,HttpServletResponse response,Object command,BindException errors)
	throws Exception{
	
		User people=(User)command;			
		User people2=this.userService.getUserBySign(this.getSessionInfo(request).getSign());
		String oldPassword=request.getParameter("oldPassword");
		if(!oldPassword.equals(people2.getPass())){
			errors.rejectValue("pass", "");
			request.setAttribute("oldPasswordErr", "旧密码输入错误");
		}else{
			people2.setPass(people.getPass());
			this.userService.updateUser(people2);
		}
	}
	
	private UserService userService;
	
	public void setUserService(UserService userService) {
		this.userService = userService;
	}





}
